package Queuedemo;

import java.util.LinkedList;
import java.util.Queue;
//最近请求次数OJ题目
public class RecentCounter {
    private Queue<Integer> requests;
    public RecentCounter() {
        requests = new LinkedList<>();
    }

    public int ping(int t) {
        requests.offer(t);
        while((!requests.isEmpty())&&requests.peek()<(t-3000)){
            requests.poll();
        }
        return requests.size();

    }
}
